#!/bin/bash

. /etc/init.d/functions

function usage() {
   echo $"usage $0 URL"
   exit 3
}

function check_url() {
   wget --spider -q -o /dev/null --tries=2 -T 5 $1
   if [ $? -eq 0 ];then
      action  "$1 is ok." /bin/true
   else
      action  "$1 is down." /bin/false
   fi
}

function main() {
   if [ $# -ne 1 ];then
      usage
   else
      check_url $1
   fi
}

main $*
